# version:1
FROM python:3.8-alpine

WORKDIR /home/app
COPY requirements.txt  /home/app

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories 
RUN apk --no-cache add gcc curl vim busybox-extras \
    libldap libjpeg jpeg-dev libc-dev musl-dev  \
    python-dev openldap-dev zlib-dev libffi-dev
RUN pip --no-cache-dir install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com --upgrade pip
RUN pip --no-cache-dir install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com -r requirements.txt

COPY . /home/app
RUN  rm -rf /home/app/env /home/app/db.sqlite3 /home/app/logs/access.log /root/.cache/pip  /var/cache/apk/*

EXPOSE 8000
# RUN  python manage.py makemigrations  &&  python manage.py migrate
CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000"]


# docker build -t lghost/cmdb:latest . -f Dockerfile # 构建
# docker build -t lghost/cmdb:v1 . -f Dockerfile-CI # 基于基础包构建
# docker push lghost/cmdb:latest # 提交到dockerhub

## 私有库tag
# docker tag lghost/cmdb:latest harbor.opsbase.cn/public/cmdb:latest

## 简洁启动
# docker run  -d -p8000:8000  --name cmdb  lghost/cmdb:latest

## 初始化数据
# docker exec -it cmdb python init.py